<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib prefix="s" uri="/struts-tags"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml-transitional.dtd">
<html>
<head>
<title>安徽大学研究生联合培养网站-后台管理系统</title>
<meta http-equiv="content-type" content="text/html;charset=utf-8"/>
<meta name="keywords" content="安徽大学研究生联合培养网站-后台管理系统"/>
<meta name="description" content="安徽大学研究生联合培养网站-后台管理系统"/>
<script src="${pageContext.request.contextPath}/scripts/jquery_treeview/jquery.js" type="text/javascript"></script>
<link rel="stylesheet" href="${pageContext.request.contextPath}/scripts/jquery_treeview/jquery.treeview.css" />
<script src="${pageContext.request.contextPath}/scripts/jquery_treeview/jquery.treeview.js"></script>
<script src="${pageContext.request.contextPath}/scripts/rightMain.js" type="text/javascript"></script>	
	<script type="text/javascript">
		$(function(){
			// 给所有的权限复选框添加事件
			$("[name=privilegeIds]").click(function(){
				// 自己选中或取消时，把所有的下级权限也都同时选中或取消
				$(this).siblings("ul").find("input").attr("checked", this.checked);
				// 当选中一个权限时，也要同时选中所有的直系上级权限
				if(this.checked){
					$(this).parents("li").children("input").attr("checked", true);
				}
				// 当取消一个权限时，同级没有选中的权限了，就也取消他的上级权限，再向上也这样做。
				else{
					if( $(this).parent().siblings("li").children("input:checked").size() == 0 ){
						$(this).parent().parent().siblings("input").attr("checked", false);
						
						var start = $(this).parent().parent();
						if( start.parent().siblings("li").children("input:checked").size() == 0 ){
							start.parent().parent().siblings("input").attr("checked", false);
						}
					}
				}
			});
			
		});
	</script>
<style>
	body{
		background: #eef2fb;
	}
	#root.ul,#root.li{
		list-style: none;
	}
</style>
</head>
<body>
<table width="100%" border="0" cellpadding="0" cellspacing="0">
 <s:form action="userAction_setPrivilege">
  <tr>
    <td width="17" valign="top" background="${pageContext.request.contextPath}/styles/images/mail_leftbg.gif"><img src="${pageContext.request.contextPath}/styles/images/left-top-right.gif" width="17" height="29" /></td>
    <td valign="top" background="${pageContext.request.contextPath}/styles/images/content-bg.gif"><table width="100%" height="31" border="0" cellpadding="0" cellspacing="0" class="left_topbg" id="table2">
      <tr>
        <td height="31"><div class="titlebt">${user.name}的权限设置 </div></td>
      </tr>
    </table>
    </td>
    <td width="16" valign="top" background="${pageContext.request.contextPath}/styles/images/mail_rightbg.gif"><img src="${pageContext.request.contextPath}/styles/images/nav-right-bg.gif" width="16" height="29" /></td>
  </tr>
  <tr>
    <td valign="middle" background="${pageContext.request.contextPath}/styles/images/mail_leftbg.gif">&nbsp;</td>
    <td valign="top" bgcolor="#F7F8F9">
    <table width="98%" border="0" align="center" cellpadding="0" cellspacing="0">
      <tr>
        <td colspan="2" valign="top" width="80%">&nbsp;</td>
        <td width="5%">&nbsp;</td>
        <td valign="top" width="15%">&nbsp;</td>
      </tr>
      <tr>
      
        <td colspan="2" valign="top"><span class="left_bt">请修改${user.name }的权限</span><br>
        <input type="checkbox" onclick="$('[name=privilegeIds]').attr('checked', this.checked)" id="cbSelectAll"/>
        <label for="cbSelectAll">全选</label><br>
       	<s:hidden name="id"></s:hidden>
       	<ul id="root">
       	<!-- 第一级 -->
       	<s:iterator value="#topPrivilegeList">
	       	<li><input type="checkbox" name="privilegeIds" value="${id }" id="cb_${id }" <s:property value="%{id in privilegeIds ? 'checked':''}" />>
	       		<label for="cb_${id }"><span class="folder">${name}</span></label>
	       		<ul>
	       		<!-- 第二级 -->
	       			<s:iterator value="children">
	       				<li>
	       					<input type="checkbox" name="privilegeIds" value="${id}" id="cb_${id}" <s:property value="%{id in privilegeIds ? 'checked':''}" />>
	       					<label for="cb_${id }"><span class="folder">${name}</span></label>
	       				</li>
	       			</s:iterator>
	       		</ul>
	       	</li>
       	</s:iterator>
       	</ul>
       <script type="text/javascript">
       	$('#root').treeview();
       </script>
       	<s:submit value="提交"></s:submit>
        </td>
        <td width="5">&nbsp;</td>
        <td width="15%" valign="top"><table width="100%" height="144" border="0" cellpadding="0" cellspacing="0" class="line_table">
          <tr>
            <td height="5" colspan="2">&nbsp;</td>
          </tr>
        </table></td>
      </tr>
      <tr>
        <td colspan="2">&nbsp;</td>
        <td>&nbsp;</td>
        <td>&nbsp;</td>
      </tr>
      
      <tr>
        <td height="40" colspan="4"><table width="100%" height="1" border="0" cellpadding="0" cellspacing="0" bgcolor="#CCCCCC">
          <tr>
            <td></td>
          </tr>
        </table></td>
      </tr>
      <tr>
        <td width="2%">&nbsp;</td>
        <td width="51%" class="left_txt"><img src="${pageContext.request.contextPath}/styles/images/icon-mail2.gif" width="16" height="11"> 管理员QQ：403278819<br>
              <img src="${pageContext.request.contextPath}/styles/images/icon-phone.gif" width="17" height="14"> <a href="indexAction_index.action" target="_bank">进入前台</a></td>
        <td>&nbsp;</td>
        <td>&nbsp;</td>
      </tr>
    </table></td>
    <td background="${pageContext.request.contextPath}/styles/images/mail_rightbg.gif">&nbsp;</td>
  </tr>
  <tr>
    <td valign="bottom" background="${pageContext.request.contextPath}/styles/images/mail_leftbg.gif"><img src="${pageContext.request.contextPath}/styles/images/buttom_left2.gif" width="17" height="17" /></td>
    <td background="${pageContext.request.contextPath}/styles/images/buttom_bgs.gif"><img src="${pageContext.request.contextPath}/styles/images/buttom_bgs.gif" width="17" height="17"></td>
    <td valign="bottom" background="${pageContext.request.contextPath}/styles/images/mail_rightbg.gif"><img src="${pageContext.request.contextPath}/styles/images/buttom_right2.gif" width="16" height="17" /></td>
  </tr></s:form>
</table>
</body>
</html>

